//
//  HomeTableViewController.swift
//  Sina
//
//  Created by 沈方武 on 15/9/27.
//  Copyright © 2015年 沈方武. All rights reserved.
//

import UIKit

class HomeTableViewController: PublishViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        if !login
        {
            visitorView?.setUpVisitorView(true, homeIconImageNmae: "visitordiscover_feed_image_house", info: "关注一些人，回这里看看有什么惊喜")
            return
        }

        setUpTitleButton()
        
    }
    
    
    func setUpTitleButton()
    {
        // 添加左右item
        navigationItem.leftBarButtonItem = UIBarButtonItem(image: "navigationbar_friendattention", target: self, action: "leftBtnClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(image: "navigationbar_pop", target: self, action: "rightBtnClick")
       
        // 添加 title
        let titleButton = TilteButton()
        titleButton.titleLabel?.textColor = UIColor.redColor()
        
        titleButton.setTitle("飞度"+"  ", forState: UIControlState.Normal)
        
        titleButton.setImage(UIImage(named: "navigationbar_arrow_down") , forState: UIControlState.Normal)
        titleButton.setImage(UIImage(named: "navigationbar_arrow_up"), forState: UIControlState.Selected)
        
        
        
        // 给title添加监听
        titleButton.addTarget(self, action: Selector("titleClicked:"), forControlEvents: UIControlEvents.TouchUpInside)
        
        navigationItem.titleView = titleButton
        
        
        
    }
    
    func titleClicked(btn: UIButton)
    {
        print(__FUNCTION__)
        btn.selected = !btn.selected
    }
    
    func leftBtnClick()
    {
         print(__FUNCTION__)
    }
    
    func rightBtnClick()
    {
          print(__FUNCTION__)
    }
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 0
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 0
    }

}
